package dto

import (
	"tuowei.com/app/admin/models"
	"tuowei.com/common/dto"
	common "tuowei.com/common/models"
)

type knowledgePoints struct {
	Name string `json:"name"`
}

type SysSubjectInsertReq struct {
	Id              int                `json:"id" comment:"主键ID"`
	Name            string             `json:"name" comment:"科目名称" vd:"@:len($)>0; msg:'科目名称不能为空'"`
	KnowledgePoints []*knowledgePoints `json:"knowledge_points" comment:"科目知识点"`
	Province        string             `json:"province" comment:"适用地区" vd:"@:len($)>0; msg:'请选择适用区域'"` //适用区域
	common.ControlBy
}

func (s *SysSubjectInsertReq) Generate(model *models.SysSubject) {
	//model.CourseId = s.CourseId
	model.Name = s.Name
	model.CreateBy = s.CreateBy
	model.Creator = s.Creator
	model.Province = s.Province
}

func (s *SysSubjectInsertReq) GetId() interface{} {
	return s.Id
}

type SysSubjectGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name" search:"type:exact;column:name;table:sys_subject" comment:"科目名称"`
	Province       string `form:"province" search:"type:exact;column:province;table:sys_subject" comment:"请选择适用区域"` //适用区域

}

type SysSubjectGetListReq struct {
	Province string `form:"province" search:"type:exact;column:province;table:sys_subject" comment:"请选择适用区域"` //适用区域
}

func (m *SysSubjectGetListReq) GetNeedSearch() interface{} {
	return *m
}

func (m *SysSubjectGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysSubjectUpdateReq struct {
	Id              int    `json:"id" comment:"主键ID" vd:"$>0;msg:'更新ID不能为空'"`
	Name            string `json:"name" comment:"科目名称" vd:"@:len($)>0;msg:'科目名称不能为空'"`
	KnowledgePoints string `json:"knowledge_points" comment:"科目知识点" vd:"@:len($)>0; msg:'请填写知识点ID'"`
	Province        string `json:"province" comment:"适用地区" vd:"@:len($)>0; msg:'请选择适用区域'"` //适用区域
	common.ControlBy
}

func (s *SysSubjectUpdateReq) Generate(model *models.SysSubject) {
	if s.Id != 0 {
		model.Id = s.Id
	}
	model.Name = s.Name
	model.UpdateBy = s.UpdateBy
	model.Updater = s.Updater
	model.Province = s.Province
}

func (s *SysSubjectUpdateReq) GetId() interface{} {
	return s.Id
}

type SysSubjectById struct {
	dto.ObjectById
	common.ControlBy
}

type SysKnowledgePointById struct {
	dto.ObjectById
	common.ControlBy
}

type SysKnowledgePointsInsertReq struct {
	SubjectId      int    `json:"subject_id" comment:"科目ID" vd:"$>0; msg:'科目ID不能为空'"`
	KnowledgePoint string `json:"knowledge_point" vd:"@:len($)>0; msg:'知识点名称不能为空'"`
}

func (s *SysKnowledgePointsInsertReq) Generate(point *models.SysKnowledgePoint) {
	point.SubjectId = s.SubjectId
	point.Name = s.KnowledgePoint
}
